package com.gewu.ordlelist.database.dbdao;

import android.content.Context;


import com.gewu.ordlelist.database.MyDatabase;
import com.gewu.ordlelist.database.dbbean.UserBeanIn;
import com.gewu.ordlelist.utils.IMenyInDaoModel;
import com.j256.ormlite.dao.Dao;

import java.sql.SQLException;
import java.util.List;

public class UserDaoPerson implements IMenyInDaoModel {

    private Dao<UserBeanIn,Integer> aliBeanIns;

    public UserDaoPerson(Context context) {
        try {
            this.aliBeanIns = MyDatabase.getInstance(context).getDao(UserBeanIn.class);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }


    @Override
    public int add(Object u) {
        try {
            UserBeanIn ifNotExists = aliBeanIns.createIfNotExists((UserBeanIn) u);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return 0;
    }

    @Override
    public int delect(int id) {
        return 0;
    }

    @Override
    public List<UserBeanIn> quer() {
        List<UserBeanIn> aliBeanIn = null;
        try {
            aliBeanIn = aliBeanIns.queryForAll();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return aliBeanIn;
    }

    @Override
    public List<UserBeanIn> querLike(String values) {
        List<UserBeanIn> time=null;
        try {
            time = aliBeanIns.queryForEq("name",values);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return time;
    }

    public void Qusear(UserBeanIn id){
        try {
            int update = aliBeanIns.update(id);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }


}
